package com.livedocumentation.client.web.description;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.livedocumentation.client.GWTEntryPoint;
import com.livedocumentation.client.model.ProjectClass;
import com.livedocumentation.client.web.MainPage;
import com.livedocumentation.client.web.menu.Menu;

/**
 * 
 * @Feature
 */
public class ListEntriesFiltered extends VerticalPanel {

	public ListEntriesFiltered(String tagType) {

		MainPage.documentationPanel.clear();

		VerticalPanel vp = new VerticalPanel();
		vp.setSpacing(40);

		for (final ProjectClass entry : GWTEntryPoint.sourceFeatures) {

			if (entry.getFeatureType() != null
					&& entry.getFeatureType().equals(tagType)) {

				String name = "<br><B>" + entry.getFeatureName() + "</B> ";

				String description = "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
						+ entry.getFeatureDescription();

				HTML html = new HTML(name + description);

				html.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent sender) {

						Menu.untoggleLinks();

						MainPage.documentationPanel.clear();

						MainPage.documentationPanel
								.add(new FeaturePanel(entry));
					}
				});

				vp.add(html);
			}

			this.add(vp);

		}

		MainPage.documentationPanel.add(this);
	}

}